package IO_;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * OutputStream:以字节为单位输出文件
 */
public class Io06 {
    public static void main2(String[] args) {
        try(OutputStream outputStream=new FileOutputStream("./test.exe") ){
            int n=100;
            outputStream.write(n);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public static void main1(String[] args) {
        try(OutputStream outputStream=new FileOutputStream("./test.exe",true) ){
            byte[] buffer=new byte[]{97,98,99,100,101,102};
            outputStream.write(buffer);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public static void main(String[] args) {
        try(OutputStream outputStream=new FileOutputStream("./test.exe") ){
            byte[] buffer=new byte[]{97,98,99,100,101,102};
            outputStream.write(buffer,0,2);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
